package com.ukao.steward.adapter;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ukao.steward.R;
import com.ukao.steward.base.ListBaseAdapter;
import com.ukao.steward.base.SuperViewHolder;
import com.ukao.steward.bean.WaitingOrderBean;
import com.ukao.steward.consts.Constant;
import com.ukao.steward.util.ActivityUtils;
import com.ukao.steward.util.CheckUtils;
import com.ukao.steward.widget.StateButton;

import java.util.List;


public class DontTakerAdapter extends ListBaseAdapter<WaitingOrderBean.ListBean > {



    public DontTakerAdapter(Context context, List<WaitingOrderBean.ListBean > mDataList) {
        super(context, mDataList);
    }

    @Override
    public int getLayoutId() {
        return R.layout.adapter_dont_taker;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, final int position) {
        TextView storeName=holder.getView(R.id.storeName);
        TextView payStatusText=holder.getView(R.id.payStatusText);
        TextView storeTel=holder.getView(R.id.storeTel);
        TextView orderNo=holder.getView(R.id.orderNo);
        TextView business=holder.getView(R.id.business);
        TextView sendName=holder.getView(R.id.sendName);
        TextView sendPhone=holder.getView(R.id.sendPhone);
        TextView productCnt=holder.getView(R.id.productCnt);
        TextView paymentPrice=holder.getView(R.id.paymentPrice);
        StateButton takeBtn=holder.getView(R.id.take_btn);

        LinearLayout storeTelLayout=holder.getView(R.id.storeTel_layout);
        LinearLayout sendPhonelayout=holder.getView(R.id.sendPhone_layout);
        WaitingOrderBean.ListBean item = mDataList.get(position);
        storeName.setText(CheckUtils.isEmptyString(item.getStoreName()));
        payStatusText.setText(item.getPayStatusText());
        orderNo.setText(item.getOrderNo());
        storeTel.setText(CheckUtils.isEmptyString(item.getStoreTel()));
        business.setText(Constant.getbusiness(item.getBusiness()));
        sendName.setText(CheckUtils.isEmptyString(item.getSendName()));
        sendPhone.setText(CheckUtils.isEmptyString(item.getSendPhone()));


        payStatusText.setTextColor(item.getPayStatus() ? getColors(R.color.green) : getColors(R.color.red));
        productCnt.setText("衣物"+item.getProductCnt()+"件，附件"+item.getAnnexCnt()+"件");

        if(!CheckUtils.isNull(item.getPaymentPrice())){
            paymentPrice.setText(item.getPayStatus() ? "已付款：￥" +CheckUtils.isEmptyNumber(item.getModifyPrice()) : "需付款：￥" +CheckUtils.isEmptyNumber(item.getModifyPrice()) );
            paymentPrice.setTextColor(item.getPayStatus() ? getColors(R.color.green) : getColors(R.color.red));

        }
        View.OnClickListener  OnClickListener= new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                WaitingOrderBean.ListBean item = mDataList.get(position);
                switch (v.getId()){
                    case R.id.sendPhone_layout :
                        if (!CheckUtils.isEmpty(item.getSendPhone())){
                            ActivityUtils.callActivity(mContext,item.getSendPhone());
                        }
                        break;
                    case R.id.storeTel_layout :
                        if (!CheckUtils.isEmpty(item.getStoreTel())){
                            ActivityUtils.callActivity(mContext,item.getStoreTel());
                        }
                        break;
                    case R.id.take_btn :
                        if (mOnItemChildClickListener!=null){
                            mOnItemChildClickListener.onChildItemClick(v.getId(), position,item);
                        }

                        break;

                }


            }
        };
        takeBtn.setOnClickListener(OnClickListener);
       // storeTelLayout.setOnClickListener(OnClickListener);
       // sendPhonelayout.setOnClickListener(OnClickListener);
    }


}
